package com.example.musicbox.controller;


import com.example.musicbox.service.impl.MUListenServiceImpl;
import com.example.musicbox.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 帅哥是我
 * @since 2022-08-02
 */
@RestController
@RequestMapping("/m-ulisten")
public class MUListenController {

    @Resource
    private MUListenServiceImpl muListenService;


    /**
     * @api {POST} /m-ulisten/userListenLife 用户听歌生涯记录
     * @apiVersion 1.0.0
     * @apiGroup 用户音乐控制器
     * @apiName userListenLife
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * {
     *     "p":1,
     *     "s":10
     * }
     * @apiParam (请求体) {Object} requestBody
     * @apiParamExample 请求体示例
     * {}
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/userListenLife")
    public Result userListenLife(@RequestHeader String token, @RequestBody Map map)
    {
        Integer p = (Integer) map.get("p");
        Integer s = (Integer) map.get("s");
        return muListenService.userListenLife(token,p,s);
    }


    /**
     * @api {POST} /m-ulisten/sumListenCount 用户某一首歌曲的听歌次数
     * @apiVersion 1.0.0
     * @apiGroup 音乐控制器
     * @apiName sumListenCount
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * {
     *     "mId":1
     * }
     * @apiParam (请求体) {Object} requestBody
     * @apiParamExample 请求体示例
     * {}
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/sumListenCount")
    public Result sumListenCount(@RequestBody Map map,@RequestHeader String token)
    {
        Integer mId = (Integer) map.get("mId");
        return muListenService.sumListenCount(mId,token);
    }

}

